{include file="public/header" /}
<link rel="stylesheet" type="text/css" href="/static/admin/webupload/webuploader.css">
<link rel="stylesheet" type="text/css" href="/static/admin/webupload/style.css">
<style>
.file-item{float: left; position: relative; width: 110px;height: 110px; margin: 0 20px 20px 0; padding: 4px;}
.file-item .info{overflow: hidden;}
.uploader-list{width: 100%; overflow: hidden;}
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加结果页</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal" name="resultAdd" id="resultAdd" method="post" action="{:url('resultAdd')}">

                        <div class="form-group">
                            <label class="col-sm-3 control-label">关联结果标识：</label>
                            <div class="input-group col-sm-4">
                                <input type="hidden" id="result_ids" name="result_ids"/>
                                <select class="form-control m-b chosen-select"  id="result_ids1" multiple>
                                    <option value="">==请选择==</option>
                                    {if !empty($option)}
                                    {foreach name="option" item="vo"}
                                    <option value="{$vo.id}">{$vo.name}</option>
                                    {/foreach}
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">标题：</label>
                            <div class="input-group col-sm-4">
                                <input id="title" type="text" class="form-control" name="title" >
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">描述：</label>
                            <div class="input-group col-sm-4">
                                <textarea id="remark" type="text" class="form-control" name="remark" ></textarea>

                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">echarts类型：</label>
                            <div class="input-group col-sm-4">
                                <select class="form-control m-b chosen-select" name="echarts_type" id="echarts_type" onchange="showDiv()">
                                    <option value="">==请选择==</option>
                                    <option value="1">总分</option>
                                    <option value="2">维度分析</option>
                                </select>
                            </div>
                        </div>

                        <div id="one" style="display: none">
<!--                            <div class="hr-line-dashed"></div>-->
<!--                            <div class="form-group">-->
<!--                                <label class="col-sm-3 control-label">维度最高分：</label>-->
<!--                                <div class="input-group col-sm-4">-->
<!--                                    <input id="wd_max_point" type="text" class="form-control" name="wd_max_point">-->
<!--                                </div>-->
<!--                            </div>-->
<!--                            <div class="hr-line-dashed"></div>-->
<!--                            <div class="form-group">-->
<!--                                <label class="col-sm-3 control-label">维度最低分：</label>-->
<!--                                <div class="input-group col-sm-4">-->
<!--                                    <input id="wd_min_point" type="text" class="form-control" name="wd_min_point">-->
<!--                                </div>-->
<!--                            </div>-->
                        </div>

                        <div id="two" style="display: none">
<!--                            <div class="hr-line-dashed"></div>-->
<!--                            <div class="form-group">-->
<!--                                <label class="col-sm-3 control-label">总分：</label>-->
<!--                                <div class="input-group col-sm-4">-->
<!--                                    <input id="all_point" type="text" class="form-control" name="all_point">-->
<!--                                </div>-->
<!--                            </div>-->
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">排序：</label>
                            <div class="input-group col-sm-4">
                                <input id="sort" type="text" class="form-control" name="sort" placeholder="排序越小越靠前" >

                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否显示：</label>
                            <div class="col-sm-6">
                                <div class="radio i-checks">
                                    <input type="radio" name='is_show' value="1" checked="checked"/>显示&nbsp;&nbsp;
                                    <input type="radio" name='is_show' value="-1" />隐藏
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript" src="/static/admin/webupload/webuploader.min.js"></script>

<script type="text/javascript">

    function showDiv()
    {
        var tt = $('#echarts_type').val();
        $('#one').hide();
        $('#two').hide();
        if(tt == 2){
            $('#one').show();
        }
        if(tt == 1){
            $('#two').show();
        }
    }

    //提交
    $(function(){
        $('#resultAdd').ajaxForm({
            beforeSubmit: checkForm, 
            success: complete, 
            dataType: 'json'
        });





        function checkForm(){

            // if( '' == $.trim($('#title').val())){
            //     layer.msg('请输入标题',{icon:2,time:1500,shade: 0.1}, function(index){
            //         layer.close(index);
            //     });
            //     return false;
            // }

            if( '' == $.trim($('#remark').val())){
                layer.msg('请输入描述',{icon:2,time:1500,shade: 0.1}, function(index){
                layer.close(index);
                });
                return false;
            }
            // if( 2 == $.trim($('#echarts_type').val())){
            //     if('' == $.trim($('#wd_max_point').val()) || '' == $.trim($('#wd_min_point').val())){
            //         layer.msg('请输入维度最高分/最低分',{icon:2,time:1500,shade: 0.1}, function(index){
            //             layer.close(index);
            //         });
            //         return false;
            //     }
            //
            // }

            // if( 1 == $.trim($('#echarts_type').val())){
            //     if('' == $.trim($('#all_point').val())){
            //         layer.msg('请输入总分',{icon:2,time:1500,shade: 0.1}, function(index){
            //             layer.close(index);
            //         });
            //         return false;
            //     }
            //
            // }


        }


        function complete(data){
            if(data.code==1){
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                    window.location.href="{:url('Result/index')}";
                });
            }else{
                layer.msg(data.msg, {icon: 5,time:1500,shade: 0.1});
                return false;   
            }
        }
    });


    $('#result_ids1').change(function(){
        var o=document.getElementById('result_ids1').getElementsByTagName('option');
        var all="";
        console.log(o[1]);
        for(var i=0;i<o.length;i++){
            if(o[i].selected){
                all+=o[i].value+",";
            }
        }

        all = all.substr(0, all.length - 1);//去掉末尾的逗号
        $("#result_ids").val(all);//赋值给隐藏的文本框
    })


    //IOS开关样式配置
   var elem = document.querySelector('.js-switch');
        var switchery = new Switchery(elem, {
            color: '#1AB394'
        });
    var config = {
        '.chosen-select': {},                    
    }
    for (var selector in config) {
        $(selector).chosen(config[selector]);
    }

</script>
</body>
</html>